package com.beordie.control;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @Classname MenuController
 * @Description TODO
 * @Date 2021/6/22 21:19
 * @Created 30500
 */
@WebServlet(urlPatterns = {"/power/menu/menus"})
public class MenuController extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 反射分发消息到对应的处理方法
        String methodString = req.getParameter("method");

        try {
            // 取出对应的方法
            Method method = this.getClass().getDeclaredMethod(methodString, HttpServletRequest.class, HttpServletResponse.class);
            try {
                method.invoke(this, req, resp);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }

    /**
     * @description 查询全部数据
     * @author 30500
     * @date 2021/6/22 21:21
     * @type [javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse]
     * @return void
     */
    protected void select(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
